#ifndef LOGINFORM_H
#define LOGINFORM_H

#include <CommonUtils.h>
#include <QWidget>
#include <data/UserInfo.pb.h>
#include <database/SQLiteUtils.h>
#include <method/Method.pb.h>
#include <method/Request.pb.h>
#include <method/Response.pb.h>
#include <module/basicwindows.h>

using namespace proto;

namespace Ui {
    class LoginForm;
}

class LoginForm : public BasicWindows {
    Q_OBJECT

    const QString STRING_CONNECTED    = "登录";
    const QString STRING_DISCONNECTED = "连接网络中...";

public:
    explicit LoginForm(QWidget* parent = nullptr);
    ~LoginForm();

protected:
    bool eventFilter(QObject *obj, QEvent *event) override;
    
signals:
    void signalTryConncet();

protected:
    void initConnections();
    void onBtnLoginClicked(bool checked);
    void onBtnRegisterClicked(bool);
    void success();

    void initList();

public slots:
    void onTcpConnected(bool isConnected);
    void onLogin(int code, QString message);
    void onComboBoxAccountTextChange(const QString& arg);

private:
    bool                isConnected = true;
    Ui::LoginForm*      ui;
    LoginAccount        loginAccount;
    QList<LoginAccount> list;
};

#endif  // LOGINFORM_H
